import "package:flutter/material.dart";
import "package:myapp/_common/Tag.dart";
import "animate.class.dart";

// ignore: must_be_immutable
class AnimateCard1 extends StatelessWidget {
  AnimateHotItem item;
  AnimateCard1({
    super.key,
    required this.item,
  });
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.only(bottom: 5),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(6),
            child: Stack(
              children: [
                AspectRatio(
                  aspectRatio: 3 / 2.3,
                  child: Image.asset(
                    item.coverUrl,
                    fit: BoxFit.cover,
                  ),
                ),
                Positioned(
                  bottom: 0,
                  left: 0,
                  right: 0,
                  child: Container(
                    width: double.infinity,
                    padding: const EdgeInsets.only(left: 6, right: 6),
                    height: 24,
                    decoration: const BoxDecoration(
                      gradient: LinearGradient(
                        begin: Alignment.bottomCenter,
                        end: Alignment.topCenter,
                        colors: [
                          Color.fromARGB(120, 0, 0, 0),
                          Color.fromARGB(80, 0, 0, 0),
                          Color.fromARGB(40, 0, 0, 0),
                          Color.fromARGB(0, 0, 0, 0),
                        ],
                      ),
                    ),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Text(
                          '${item.partition}·${item.type}',
                          style: const TextStyle(
                            color: Colors.white,
                            fontSize: 10,
                          ),
                        ),
                        Text(
                          '更新至第${item.episodes}话',
                          style: const TextStyle(
                            color: Colors.white,
                            fontSize: 10,
                          ),
                        )
                      ],
                    ),
                  ),
                ),
                item.tagType != null
                    ? Positioned(
                        top: 4,
                        right: 0,
                        child: Container(
                          height: 16,
                          padding: const EdgeInsets.only(left: 6, right: 2),
                          decoration: const BoxDecoration(
                            borderRadius: BorderRadius.only(
                              topLeft: Radius.circular(15),
                              bottomLeft: Radius.circular(15),
                            ),
                            color: Color.fromARGB(255, 68, 194, 252),
                          ),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              Text(
                                item.tag ?? '',
                                style: const TextStyle(
                                  color: Colors.white,
                                  fontSize: 10,
                                ),
                              )
                            ],
                          ),
                        ),
                      )
                    : const SizedBox.shrink()
              ],
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.only(bottom: 2),
          child: Text(
            item.title,
            maxLines: 1,
            overflow: TextOverflow.ellipsis,
            style: const TextStyle(fontSize: 13),
          ),
        ),
        Row(
          children: [
            Expanded(
              child: Row(
                children: [
                  double.parse(item.score) > 9.0
                      ? Tag(item.score)
                      : const SizedBox.shrink(),
                  Expanded(
                    child: Text(
                      item.subTitle,
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      style: const TextStyle(
                        fontSize: 11,
                        color: Colors.black38,
                      ),
                    ),
                  ),
                ],
              ),
            ),
            const Icon(
              Icons.more_vert,
              size: 16,
              color: Colors.black38,
            ),
          ],
        ),
      ],
    );
  }
}
